//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================
#if _MSC_VER > 1000
#pragma once
#endif

#ifndef __GHOSTMUTEX_H__
#define __GHOSTMUTEX_H__

#include <elasys_server.h>
#include <interlocked.h>
#include "ghost.h"

class CGhostMutex: public Ghost
{
public:
    UInt32 AddRef();
    UInt32 Release();

public:
    CGhostMutex(): m_hMutex(NULL) {}
    virtual ~CGhostMutex();

    ECode Initialize(
        /* [in] */ WString name);

private:
    PVoid m_hMutex;
private:
    Interlocked m_nRefs;
};

class CGhostMutexFactory: public GhostFactory
{
public:
    ECode CreateGhost(
        /* [out] */ Ghost ** ppGhost,
        /* [out] */ Boolean * pExisted);

public:
    CGhostMutexFactory(WString name):
            GhostFactory(name, ObjectType_NamedMutex) {}
};

#endif //__GHOSTMUTEX_H__

